CC = gcc
CFLAGS = -Wall -Wextra
CPPFLAGS = -I$(HEADERS_DIR)

BASE_DIR = ./
HEADERS_DIR = $(BASE_DIR)headers/
SOURCES_DIR = $(BASE_DIR)src/
OBJECTS_DIR = $(BASE_DIR)objs/

HEADERS = 
SOURCES = lib1.c
OBJECTS = lib1.o

HEADERS_LIST = $(addprefix $(HEADERS_DIR), $(HEADERS))
SOURCES_LIST = $(addprefix $(SOURCES_DIR), $(SOURCES))
OBJECTS_LIST = $(addprefix $(OBJECTS_DIR), $(OBJECTS))

.PHONY: all clean

all: $(OBJECTS_LIST)
	$(CC) -shared $^ -o liblib1.so

$(OBJECTS_DIR)%.o: $(SOURCES_DIR)%.c $(HEADERS_LIST)
	$(CC) -c -fPIC $(CFLAGS) $(CPPFLAGS) $< -o $@
	
clean:
	rm *so $(OBJECTS_LIST)
